/*
 * Project Porcupine
 * Copyright (C) 2012  Team Porcupine
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
*
* @author Martin "quill18" Glaude <quill18@towerdive.com>
*/

package com.towerdive.porcupine;

import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.renderer.RenderManager;
import com.jme3.system.AppSettings;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Main extends SimpleApplication {
    
    public static Main app;
    private BulletAppState bulletAppState;

    public static void main(String[] args) {
        /**
         * Trying to limit the log spam to relevant data
         */
        Logger.getLogger("").setLevel(Level.WARNING);

        /**
         * The settings box is annoying for testing, set reasonable 
         * defaults here.
         */
        AppSettings s = new AppSettings(true);
        s.setResolution(800,600);
        s.setFrameRate(100); // Physics run weird at 200+ fps, so cap it.
        app = new Main();
        app.setSettings(s);
        app.setShowSettings(false);
        
        /**
         * Start the game!
         */
        app.start();
    }

    @Override
    public void simpleInitApp() {
        /**
         * We are using physics, so we need to create the physics app state
         * to manage this behaviour.
         */
        bulletAppState = new BulletAppState();
        stateManager.attach(bulletAppState);
        
        /**
         * This line enabled the physics debug information, which is mostly
         * the collision box wireframes.
         */
        //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
        
        /**
         * Disable the default SimpleApplication's camera controller, since
         * we are implementing our own movement code.
         */
        flyCam.setEnabled(false);
        
        /**
         * Create a GroundAppState to populate a scene.
         */
        GroundAppState groundAppState = new GroundAppState();
        stateManager.attach(groundAppState);
    }

    @Override
    public void simpleUpdate(float tpf) {
        super.simpleUpdate(tpf);
    }

    @Override
    public void simpleRender(RenderManager rm) {
    }
}
